home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / jtb.bst (.txt) < prev    next >
LaTeX Document  |  1992-07-19  |  26KB  |  985 lines

  1. %%% ====================================================================
  2. %%%  @BibTeX-style-file{
  3. %%%     author          = "Alan Rogers",
  4. %%%     version         = "1.1",
  5. %%%     date            = "1990",
  6. %%%     filename        = "humanbio.bst",
  7. %%%     address         = "Dept of Anthropology, University of Utah,
  8. %%%                        Salt Lake City, UT 84112",
  9. %%%     checksum        = "29497 1202 3234 26025",
  10. %%%     email           = "rogers@anthro.utah.edu",
  11. %%%     supported       = "no",
  12. %%%     docstring       = "The file produces bibliographies more or
  13. %%%                        less in the format of the Journal of
  14. %%%                        Theoretical Biology.  It was adapted from
  15. %%%                        Sake J. Hogeveen's `astron.bst'.
  16. %%%                        Usage: \documentstyle[astron]{...}
  17. %%%                        ...
  18. %%%                        \bibliographystyle{jtb}
  19. %%%                        ...
  20. %%%                        The \documentstyle command above invokes
  21. %%%                        Hogeveen's `astron.sty', which must be in
  22. %%%                        TeX's search path.
  23. %%%                        The modifications implement `\cite*{}',
  24. %%%                        which generates references in short form.
  25. %%%                        For example, `Rogers \cite*{...}' would
  26. %%%                        produce `Rogers (1992)'."
  27. %%%  }
  28. %%% ====================================================================
  29. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  30. % Copyright (C) 1990 Sake J. Hogeveen.
  31. % This is ASTRON.BST, a BibTeX style for use with BibTeX version 0.99c.
  32. % ASTRON.BST has to be used in conjunction with the LaTeX style ASTRON.STY.
  33. % The use of both styles is documented in ASTDOC.TEX.
  34. % ASTRON.BST is an adaptation of APALIKE.BST by Oren Patashnik and Suzan King.
  35. % This style produces citations in the `author-year' format, which is widely
  36. % used among astronomical journals.
  37. % It supports two forms of citation: the \cite command produces:  (Author, year)
  38. % in the text; the \cite* command only:  (year) .
  39. % The long an short citation trickery is adapted from NAMED.BST by
  40. % Peter F. Patel-Schneider.
  41. % Copyright Notice:
  42. % The files ASTRON.BST, ASTRON.STY, ASTDOC.TEX, ASTDOC.BIB, EXAMPLE.TEX,
  43. % EXAMPLE.BIB, MNEMONIC.BIB, and TEMPLATE.BIB are a package.
  44. % You may copy and distribute them freely for non-commercial purposes,
  45. % provided that you keep the package together and this copyright notice
  46. % in tact.
  47. % You may not alter or modify the files; this helps to ensure that all
  48. % distributions of ASTRON.BST and related files are the same.
  49. % If you make any modifications, then you must give the files new names,
  50. % other than the present.
  51. % The author bears no responsibilities for errors in this document or
  52. % the software it describes; and shall not be held liable for any indirect,
  53. % incidental, or consequential damages.
  54. ENTRY
  55.   { address
  56.     author
  57.     booktitle
  58.     chapter
  59.     edition
  60.     editor
  61.     howpublished
  62.     institution
  63.     journal
  64.     key
  65. %    month              not used in apalike
  66.     note
  67.     number
  68.     organization
  69.     pages
  70.     publisher
  71.     school
  72.     series
  73.     title
  74.     type
  75.     volume
  76.     year
  77.   { label extra.label sort.label }
  78. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  79. FUNCTION {init.state.consts}
  80. { #0 'before.all :=
  81.   #1 'mid.sentence :=
  82.   #2 'after.sentence :=
  83.   #3 'after.block :=
  84. STRINGS { s t }
  85. FUNCTION {output.nonnull}
  86. { 's :=
  87.   output.state mid.sentence =
  88.     { ", " * write$ }
  89.     { output.state after.block =
  90.         { ", " *  write$
  91.           newline$
  92.           "\newblock " write$
  93.         }
  94.         { output.state before.all =
  95.             'write$
  96.             { ", " * write$ }
  97.           if$
  98.         }
  99.       if$
  100.       mid.sentence 'output.state :=
  101.     }
  102.   if$
  103. FUNCTION {output.nonnull.extra}
  104. { 's :=
  105.   output.state mid.sentence =
  106.     { " " * write$ }
  107.     { output.state after.block =
  108.         { ", " *  write$
  109.           newline$
  110.           "\newblock " write$
  111.         }
  112.         { output.state before.all =
  113.             'write$
  114.             { ", " * write$ }
  115.           if$
  116.         }
  117.       if$
  118.       mid.sentence 'output.state :=
  119.     }
  120.   if$
  121. FUNCTION {output}
  122. { duplicate$ empty$
  123.     'pop$
  124.     'output.nonnull
  125.   if$
  126. FUNCTION {output.extra}
  127. { duplicate$ empty$
  128.     'pop$
  129.     'output.nonnull.extra
  130.   if$
  131. FUNCTION {output.check}
  132. { 't :=
  133.   duplicate$ empty$
  134.     { pop$ "empty " t * " in " * cite$ * warning$ }
  135.     'output.nonnull
  136.   if$
  137. FUNCTION {output.check.extra}
  138. { 't :=
  139.   duplicate$ empty$
  140.     { pop$ "empty " t * " in " * cite$ * warning$ }
  141.     'output.nonnull.extra
  142.   if$
  143. %                                       apalike needs this function because
  144. %                                       the year has special punctuation;
  145. %                                       apalike ignores the month
  146. FUNCTION {output.year.check}
  147. { year empty$
  148.     { "empty year in " cite$ * warning$ }
  149.     { write$
  150.       " (" year * extra.label * ") " *
  151.       mid.sentence 'output.state :=
  152.     }
  153.   if$
  154. FUNCTION {output.bibitem}
  155. { newline$
  156.   "\bibitem[" write$
  157.   label write$
  158.   "]{" write$
  159.   cite$ write$
  160.   "}" write$
  161.   newline$
  162.   before.all 'output.state :=
  163. FUNCTION {fin.entry}
  164. { write$
  165.   newline$
  166. FUNCTION {new.block}
  167. { output.state before.all =
  168.     'skip$
  169.     { after.block 'output.state := }
  170.   if$
  171. FUNCTION {new.sentence}
  172. { output.state after.block =
  173.     'skip$
  174.     { output.state before.all =
  175.         'skip$
  176.         { after.sentence 'output.state := }
  177.       if$
  178.     }
  179.   if$
  180. FUNCTION {not}
  181. {   { #0 }
  182.     { #1 }
  183.   if$
  184. FUNCTION {and}
  185. {   'skip$
  186.     { pop$ #0 }
  187.   if$
  188. FUNCTION {or}
  189. {   { pop$ #1 }
  190.     'skip$
  191.   if$
  192. FUNCTION {new.block.checkb}
  193. { empty$
  194.   swap$ empty$
  195.   and
  196.     'skip$
  197.     'new.block
  198.   if$
  199. FUNCTION {field.or.null}
  200. { duplicate$ empty$
  201.     { pop$ "" }
  202.     'skip$
  203.   if$
  204. FUNCTION {boldface}
  205. { duplicate$ empty$
  206.     { pop$ "" }
  207.     { "{\bf " swap$ * "}" * }
  208.   if$
  209. FUNCTION {emphasize}
  210. { duplicate$ empty$
  211.     { pop$ "" }
  212.     { "{\em " swap$ * "}" * }
  213.   if$
  214. INTEGERS { nameptr namesleft numnames }
  215. FUNCTION {format.names}
  216. { 's :=
  217.   #1 'nameptr :=
  218.   s num.names$ 'numnames :=
  219.   numnames 'namesleft :=
  220.     { namesleft #0 > }
  221.     { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=   % last name first
  222.       nameptr #1 >
  223.         { namesleft #1 >
  224.             { ", " * t * }
  225.             { numnames #2 >
  226.                 { "," * }
  227.                 'skip$
  228.               if$
  229.               t "others" =
  230.                 { " et~al." * }
  231.                 { " and " * t * }
  232.               if$
  233.             }
  234.           if$
  235.         }
  236.         't
  237.       if$
  238.       nameptr #1 + 'nameptr :=
  239.       namesleft #1 - 'namesleft :=
  240.     }
  241.   while$
  242. FUNCTION {format.ed.names}
  243. { 's :=
  244.   #1 'nameptr :=
  245.   s num.names$ 'numnames :=
  246.   numnames 'namesleft :=
  247.     { namesleft #0 > }
  248.     { s nameptr "{f. }{vv~}{ll}{, jj}" format.name$ 't :=
  249.       nameptr #1 >
  250.         { namesleft #1 >
  251.             { ", " * t * }
  252.             { numnames #2 >
  253.                 { "," * }
  254.                 'skip$
  255.               if$
  256.               t "others" =
  257.                 { " et~al." * }
  258.                 { " and " * t * }
  259.               if$
  260.             }
  261.           if$
  262.         }
  263.         't
  264.       if$
  265.       nameptr #1 + 'nameptr :=
  266.       namesleft #1 - 'namesleft :=
  267.     }
  268.   while$
  269. FUNCTION {format.authors}
  270. { author empty$
  271.     { "" }
  272.     { author format.names }
  273.   if$
  274. FUNCTION {format.key}                   % this function is just for apalike
  275. { empty$
  276.     { key field.or.null }
  277.     { "" }
  278.   if$
  279. FUNCTION {format.editors}
  280. { editor empty$
  281.     { "" }
  282.     {" (" * editor format.names
  283.       editor num.names$ #1 >
  284.         { " eds.)" * }
  285.         { " ed.)" * }
  286.       if$
  287.     }
  288.   if$
  289. FUNCTION {format.editors.extra}
  290. { editor empty$
  291.     { "" }
  292.     {" (" * editor format.ed.names
  293.       editor num.names$ #1 >
  294.         { " eds.)" * }
  295.         { " ed.)" * }
  296.       if$
  297.     }
  298.   if$
  299. FUNCTION {format.title}
  300. { title empty$
  301.     { "" }
  302.     { title "t" change.case$ }
  303.   if$
  304. FUNCTION {n.dashify}
  305. { 't :=
  306.     { t empty$ not }
  307.     { t #1 #1 substring$ "-" =
  308.         { t #1 #2 substring$ "--" = not
  309.             { "--" *
  310.               t #2 global.max$ substring$ 't :=
  311.             }
  312.             {   { t #1 #1 substring$ "-" = }
  313.                 { "-" *
  314.                   t #2 global.max$ substring$ 't :=
  315.                 }
  316.               while$
  317.             }
  318.           if$
  319.         }
  320.         { t #1 #1 substring$ *
  321.           t #2 global.max$ substring$ 't :=
  322.         }
  323.       if$
  324.     }
  325.   while$
  326. FUNCTION {first.page.number}
  327. { 't :=
  328.     { t "" =
  329.         { #0 }
  330.         { t #1 #1 substring$ "-" = not }
  331.       if$
  332.     }
  333.     { t #1 #1 substring$ *
  334.       t #2 global.max$ substring$ 't :=
  335.     }
  336.   while$
  337. FUNCTION {format.btitle}
  338. { title emphasize
  339. FUNCTION {tie.or.space.connect}
  340. { duplicate$ text.length$ #3 <
  341.     { "~" }
  342.     { " " }
  343.   if$
  344.   swap$ * *
  345. FUNCTION {either.or.check}
  346. { empty$
  347.     'pop$
  348.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  349.   if$
  350. FUNCTION {format.bvolume}
  351. { volume empty$
  352.     { "" }
  353.     { "Vol." volume tie.or.space.connect
  354.       series empty$
  355.         'skip$
  356.         { " of " * series emphasize * }
  357.       if$
  358.       "volume and number" number either.or.check
  359.     }
  360.   if$
  361. FUNCTION {format.number.series}
  362. { volume empty$
  363.     { number empty$
  364.         { series field.or.null }
  365.         { output.state mid.sentence =
  366.             { "No." }
  367.             { "No." }
  368.           if$
  369.           number tie.or.space.connect
  370.           series empty$
  371.             { "there's a number but no series in " cite$ * warning$ }
  372.             { " in " * series * }
  373.           if$
  374.         }
  375.       if$
  376.     }
  377.     { "" }
  378.   if$
  379. FUNCTION {format.edition}
  380. { edition empty$
  381.     { "" }
  382.     { output.state mid.sentence =
  383.         { edition "l" change.case$ " edition" * }
  384.         { edition "t" change.case$ " edition" * }
  385.       if$
  386.     }
  387.   if$
  388. INTEGERS { multiresult }
  389. FUNCTION {multi.page.check}
  390. { 't :=
  391.   #0 'multiresult :=
  392.     { multiresult not
  393.       t empty$ not
  394.       and
  395.     }
  396.     { t #1 #1 substring$
  397.       duplicate$ "-" =
  398.       swap$ duplicate$ "," =
  399.       swap$ "+" =
  400.       or or
  401.         { #1 'multiresult := }
  402.         { t #2 global.max$ substring$ 't := }
  403.       if$
  404.     }
  405.   while$
  406.   multiresult
  407. FUNCTION {format.pages}
  408. { pages empty$
  409.     { "" }
  410.     { pages multi.page.check
  411.     { "pp." pages n.dashify tie.or.space.connect }
  412.     { "p." pages tie.or.space.connect }
  413.       if$
  414.     }
  415.   if$
  416. FUNCTION {format.page}
  417. { pages empty$
  418.     { "" }
  419.     { "p.~" pages first.page.number * }
  420.   if$
  421. FUNCTION {format.vol.num.pages}
  422. { volume field.or.null
  423.   number empty$
  424.     'skip$
  425.     { "(" number * ")" * *
  426.       volume empty$
  427.         { "there's a number but no volume in " cite$ * warning$ }
  428.         'skip$
  429.       if$
  430.     }
  431.   if$
  432.   pages empty$
  433.     'skip$
  434.     { duplicate$ empty$
  435.         { pop$ format.pages }
  436.         { boldface ", " * pages n.dashify * }
  437.       if$
  438.     }
  439.   if$
  440. FUNCTION {format.vol.num.page}
  441. { volume field.or.null
  442.   number empty$
  443.     'skip$
  444.     { "(" number * ")" * *
  445.       volume empty$
  446.         { "there's a number but no volume in " cite$ * warning$ }
  447.         'skip$
  448.       if$
  449.     }
  450.   if$
  451.   pages empty$
  452.     'skip$
  453.     { duplicate$ empty$
  454.         { pop$ format.pages }
  455.         { boldface ", " * pages first.page.number * }
  456.       if$
  457.     }
  458.   if$
  459. FUNCTION {format.chapter.pages}
  460. { chapter empty$
  461.     'format.pages
  462.     { type empty$
  463.         { "Chapt." }
  464.         { type "l" change.case$ }
  465.       if$
  466.       chapter tie.or.space.connect
  467.       pages empty$
  468.         'skip$
  469.         { ", " * format.pages * }
  470.       if$
  471.     }
  472.   if$
  473. FUNCTION {format.in.ed.booktitle}
  474. { booktitle empty$
  475.     { "" }
  476.     { editor empty$
  477.         { "In " booktitle emphasize * }
  478.     { "In " booktitle emphasize * ". " * format.editors.extra * }
  479.       if$
  480.     }
  481.   if$
  482. FUNCTION {format.thesis.type}
  483. { type empty$
  484.     'skip$
  485.     { pop$
  486.       type "t" change.case$
  487.     }
  488.   if$
  489. FUNCTION {format.tr.number}
  490. { type empty$
  491.     { "Technical Report" }
  492.     'type
  493.   if$
  494.   number empty$
  495.     { "t" change.case$ }
  496.     { number tie.or.space.connect }
  497.   if$
  498. FUNCTION {format.article.crossref}
  499. { "In"                                                  % this is for apalike
  500.   " \cite{" * crossref * "}" *
  501. FUNCTION {format.book.crossref}
  502. { volume empty$
  503.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  504.       "In "
  505.     }
  506.     { "Vol." volume tie.or.space.connect
  507.       " of " *
  508.     }
  509.   if$
  510.   "\cite{" * crossref * "}" *                           % this is for apalike
  511. FUNCTION {format.incoll.inproc.crossref}
  512. { "In"                                                  % this is for apalike
  513.   " \cite{" * crossref * "}" *
  514. FUNCTION {article}
  515. { output.bibitem
  516.   format.authors "author" output.check
  517.   author format.key output                              % special for
  518.   output.year.check                                     % apalike
  519.   new.block
  520.   crossref missing$
  521.     { journal emphasize "journal" output.check.extra
  522.       format.vol.num.page output.extra
  523.     }
  524.     { format.article.crossref output.nonnull
  525.       format.page output
  526.     }
  527.   if$
  528.   new.block
  529.   note output
  530.   fin.entry
  531. FUNCTION {book}
  532. { output.bibitem
  533.   author empty$
  534.     { format.editors "author and editor" output.check
  535.       editor format.key output
  536.     }
  537.     { format.authors output.nonnull
  538.       crossref missing$
  539.         { "author and editor" editor either.or.check }
  540.         'skip$
  541.       if$
  542.     }
  543.   if$
  544.   output.year.check                             % special for apalike
  545.   new.block
  546.   format.btitle "title" output.check
  547.   crossref missing$
  548.     { format.bvolume output
  549.       new.block
  550.       format.number.series output
  551.       new.sentence
  552.       address ": " * publisher * output
  553.     }
  554.     { new.block
  555.       format.book.crossref output.nonnull
  556.     }
  557.   if$
  558.   format.edition output
  559.   new.block
  560.   note output
  561.   fin.entry
  562. FUNCTION {booklet}
  563. { output.bibitem
  564.   format.authors output
  565.   author format.key output                              % special for
  566.   output.year.check                                     % apalike
  567.   new.block
  568.   format.btitle "title" output.check
  569.   new.block
  570.   howpublished output
  571.   address output
  572.   new.block
  573.   note output
  574.   fin.entry
  575. FUNCTION {inbook}
  576. { output.bibitem
  577.   author empty$
  578.     { format.editors "author and editor" output.check
  579.       editor format.key output
  580.     }
  581.     { format.authors output.nonnull
  582.       crossref missing$
  583.         { "author and editor" editor either.or.check }
  584.         'skip$
  585.       if$
  586.     }
  587.   if$
  588.   output.year.check                             % special for apalike
  589.   new.block
  590.   format.btitle "title" output.check
  591.   crossref missing$
  592.     { format.bvolume output
  593.       format.chapter.pages "chapter and pages" output.check
  594.       new.block
  595.       format.number.series output
  596.       new.sentence
  597.       address ": " * publisher * output
  598.     }
  599.     { format.chapter.pages "chapter and pages" output.check
  600.       new.block
  601.       format.book.crossref output.nonnull
  602.     }
  603.   if$
  604.   format.edition output
  605.   new.block
  606.   note output
  607.   fin.entry
  608. FUNCTION {incollection}
  609. { output.bibitem
  610.   format.authors "author" output.check
  611.   author format.key output                              % special for
  612.   output.year.check                                     % apalike
  613.   new.block
  614. %  format.title "title" output.check
  615. %  new.block
  616.   crossref missing$
  617.     { format.in.ed.booktitle "booktitle" output.check
  618.       format.bvolume output
  619.       format.number.series output
  620.       format.chapter.pages output
  621.       new.sentence
  622.       address ": " * publisher * output
  623.       format.edition output
  624.     }
  625.     { format.incoll.inproc.crossref output.nonnull
  626.       format.chapter.pages output
  627.     }
  628.   if$
  629.   new.block
  630.   note output
  631.   fin.entry
  632. FUNCTION {inproceedings}
  633. { output.bibitem
  634.   format.authors "author" output.check
  635.   author format.key output                              % special for
  636.   output.year.check                                     % apalike
  637.   new.block
  638. %  format.title "title" output.check
  639. %  new.block
  640.   crossref missing$
  641.     { format.in.ed.booktitle "booktitle" output.check
  642.       format.bvolume output
  643.       format.number.series output
  644.       format.pages output
  645.       new.sentence                                      % there's no year
  646.       organization output                               % here so things
  647.       address ": " * publisher * output
  648.     }
  649.     { format.incoll.inproc.crossref output.nonnull
  650.       format.pages output
  651.     }
  652.   if$
  653.   new.block
  654.   note output
  655.   fin.entry
  656. FUNCTION {conference} { inproceedings }
  657. FUNCTION {manual}
  658. { output.bibitem
  659.   format.authors output
  660.   author format.key output                              % special for
  661.   output.year.check                                     % apalike
  662.   new.block
  663.   format.btitle "title" output.check
  664.   organization address new.block.checkb
  665.   organization output
  666.   address output
  667.   format.edition output
  668.   new.block
  669.   note output
  670.   fin.entry
  671. FUNCTION {mastersthesis}
  672. { output.bibitem
  673.   format.authors "author" output.check
  674.   author format.key output                              % special for
  675.   output.year.check                                     % apalike
  676.   new.block
  677. %  format.title "title" output.check
  678. %  new.block
  679.   "Master's thesis" emphasize format.thesis.type output.nonnull
  680.   school "school" output.check
  681.   address output
  682.   new.block
  683.   note output
  684.   fin.entry
  685. FUNCTION {misc}
  686. { output.bibitem
  687.   format.authors output
  688.   author format.key output                              % special for
  689.   output.year.check                                     % apalike
  690.   new.block
  691.   format.btitle output
  692.   new.block
  693.   howpublished output
  694.   new.block
  695.   note output
  696.   fin.entry
  697. FUNCTION {phdthesis}
  698. { output.bibitem
  699.   format.authors "author" output.check
  700.   author format.key output                              % special for
  701.   output.year.check                                     % apalike
  702.   new.block
  703. %  format.btitle "title" output.check
  704. %  new.block
  705.   "Ph.D. thesis" emphasize format.thesis.type output.nonnull
  706.   school "school" output.check
  707.   address output
  708.   new.block
  709.   note output
  710.   fin.entry
  711. FUNCTION {proceedings}
  712. { output.bibitem
  713.   format.editors output
  714.   editor format.key output                              % special for
  715.   output.year.check                                     % apalike
  716.   new.block
  717.   format.btitle "title" output.check
  718.   format.bvolume output
  719.   format.number.series output
  720.   address output                                % for apalike
  721.   new.sentence                                  % we always output
  722.   organization output                           % a nonempty organization
  723.   publisher output                              % here
  724.   new.block
  725.   note output
  726.   fin.entry
  727. FUNCTION {techreport}
  728. { output.bibitem
  729.   format.authors "author" output.check
  730.   author format.key output                              % special for
  731.   output.year.check                                     % apalike
  732.   new.block
  733.   format.btitle "title" output.check
  734.   new.block
  735.   format.tr.number output.nonnull
  736.   address ": " * institution * output
  737.   new.block
  738.   note output
  739.   fin.entry
  740. FUNCTION {unpublished}
  741. { output.bibitem
  742.   format.authors "author" output.check
  743.   author format.key output                              % special for
  744.   output.year.check                                     % apalike
  745.   new.block
  746.   format.btitle "title" output.check
  747.   new.block
  748.   note "note" output.check
  749.   fin.entry
  750. FUNCTION {default.type} { misc }
  751. MACRO {jan} {"Jan."}
  752. MACRO {feb} {"Feb."}
  753. MACRO {mar} {"Mar."}
  754. MACRO {apr} {"Apr,"}
  755. MACRO {may} {"May"}
  756. MACRO {jun} {"June"}
  757. MACRO {jul} {"July"}
  758. MACRO {aug} {"Aug."}
  759. MACRO {sep} {"Sept."}
  760. MACRO {oct} {"Oct."}
  761. MACRO {nov} {"Nov."}
  762. MACRO {dec} {"Dec."}
  763. FUNCTION {sortify}
  764. { purify$
  765.   "l" change.case$
  766. INTEGERS { len }
  767. FUNCTION {chop.word}
  768. { 's :=
  769.   'len :=
  770.   s #1 len substring$ =
  771.     { s len #1 + global.max$ substring$ }
  772.     's
  773.   if$
  774. %                       There are three apalike cases: one person (Jones),
  775. %                       two (Jones and de~Bruijn), and more (Jones et~al.).
  776. %                       This function is much like format.crossref.editors.
  777. FUNCTION {format.lab.names}
  778. { 's :=
  779.   s #1 "{vv~}{ll}" format.name$
  780.   s num.names$ duplicate$
  781.   #2 >
  782.     { pop$ " et~al." * }
  783.     { #2 <
  784.         'skip$
  785.         { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  786.             { " et~al." * }
  787.             { " and " * s #2 "{vv~}{ll}" format.name$ * }
  788.           if$
  789.         }
  790.       if$
  791.     }
  792.   if$
  793. FUNCTION {author.key.label}
  794. { author empty$
  795.     { key empty$
  796.         { cite$ #1 #3 substring$ }
  797.         'key                                    % apalike uses the whole key
  798.       if$
  799.     }
  800.     { author format.lab.names }
  801.   if$
  802. FUNCTION {author.editor.key.label}
  803. { author empty$
  804.     { editor empty$
  805.         { key empty$
  806.             { cite$ #1 #3 substring$ }
  807.             'key                                % apalike uses the whole key
  808.           if$
  809.         }
  810.         { editor format.lab.names }
  811.       if$
  812.     }
  813.     { author format.lab.names }
  814.   if$
  815. FUNCTION {editor.key.label}
  816. { editor empty$
  817.     { key empty$
  818.         { cite$ #1 #3 substring$ }
  819.         'key                    % apalike uses the whole key, no organization
  820.       if$
  821.     }
  822.     { editor format.lab.names }
  823.   if$
  824. FUNCTION {calc.label}
  825. { type$ "book" =
  826.   type$ "inbook" =
  827.     'author.editor.key.label
  828.     { type$ "proceedings" =
  829.         'editor.key.label                       % apalike ignores organization
  830.         'author.key.label                       % for labeling and sorting
  831.       if$
  832.     }
  833.   if$
  834.   "\protect\astroncite{" swap$ * "}{"                   % these three lines are
  835.   *                                                     % for apalike, which
  836.   year field.or.null purify$ #-1 #4 substring$          % uses all four digits
  837.   *                       % the mathing closing "}" comes in at the reverse.pass
  838.   'label :=
  839. FUNCTION {sort.format.names}
  840. { 's :=
  841.   #1 'nameptr :=
  842.   s num.names$ 'numnames :=
  843.   numnames 'namesleft :=
  844.     { namesleft #0 > }
  845.     { nameptr #1 >
  846.         { "   " * }
  847.         'skip$
  848.       if$                                               % apalike uses initials
  849.       s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ 't := % <= here
  850.       nameptr numnames = t "others" = and
  851.         { "et al" * }
  852.         { t sortify * }
  853.       if$
  854.       nameptr #1 + 'nameptr :=
  855.       namesleft #1 - 'namesleft :=
  856.     }
  857.   while$
  858. FUNCTION {sort.format.title}
  859. { 't :=
  860.   "A " #2
  861.     "An " #3
  862.       "The " #4 t chop.word
  863.     chop.word
  864.   chop.word
  865.   sortify
  866.   #1 global.max$ substring$
  867. FUNCTION {author.sort}
  868. { author empty$
  869.     { key empty$
  870.         { "to sort, need author or key in " cite$ * warning$
  871.           ""
  872.         }
  873.         { key sortify }
  874.       if$
  875.     }
  876.     { author sort.format.names }
  877.   if$
  878. FUNCTION {author.editor.sort}
  879. { author empty$
  880.     { editor empty$
  881.         { key empty$
  882.             { "to sort, need author, editor, or key in " cite$ * warning$
  883.               ""
  884.             }
  885.             { key sortify }
  886.           if$
  887.         }
  888.         { editor sort.format.names }
  889.       if$
  890.     }
  891.     { author sort.format.names }
  892.   if$
  893. FUNCTION {editor.sort}
  894. { editor empty$
  895.     { key empty$
  896.         { "to sort, need editor or key in " cite$ * warning$
  897.           ""
  898.         }
  899.         { key sortify }
  900.       if$
  901.     }
  902.     { editor sort.format.names }
  903.   if$
  904. %                       apalike uses two sorting passes; the first one sets the
  905. %                       labels so that the `a's, `b's, etc. can be computed;
  906. %                       the second pass puts the references in "correct" order.
  907. %                       The presort function is for the first pass. It computes
  908. %                       label, sort.label, and title, and then concatenates.
  909. FUNCTION {presort}
  910. { calc.label
  911.   label sortify
  912.   "    "
  913.   type$ "book" =
  914.   type$ "inbook" =
  915.     'author.editor.sort
  916.     { type$ "proceedings" =
  917.         'editor.sort
  918.         'author.sort
  919.       if$
  920.     }
  921.   if$
  922.   #1 entry.max$ substring$      % for
  923.   'sort.label :=                % apalike
  924.   sort.label                    % style
  925.   "    "
  926.   title field.or.null
  927.   sort.format.title
  928.   #1 entry.max$ substring$
  929.   'sort.key$ :=
  930. ITERATE {presort}
  931. SORT            % by label, sort.label, title---for final label calculation
  932. STRINGS { last.label next.extra }       % apalike labels are only for the text;
  933. INTEGERS { last.extra.num }             % there are none in the bibliography
  934. FUNCTION {initialize.extra.label.stuff} % and hence there is no `longest.label'
  935. { #0 int.to.chr$ 'last.label :=
  936.   "" 'next.extra :=
  937.   #0 'last.extra.num :=
  938. FUNCTION {forward.pass}
  939. { last.label label =
  940.     { last.extra.num #1 + 'last.extra.num :=
  941.       last.extra.num int.to.chr$ 'extra.label :=
  942.     }
  943.     { "a" chr.to.int$ 'last.extra.num :=
  944.       "" 'extra.label :=
  945.       label 'last.label :=
  946.     }
  947.   if$
  948. FUNCTION {reverse.pass}
  949. { next.extra "b" =
  950.     { "a" 'extra.label := }
  951.     'skip$
  952.   if$
  953.   label extra.label * "}" * 'label :=
  954.   extra.label 'next.extra :=
  955. EXECUTE {initialize.extra.label.stuff}
  956. ITERATE {forward.pass}
  957. REVERSE {reverse.pass}
  958. %                               Now that the label is right we sort for real,
  959. %                               on sort.label then year then title.  This is
  960. %                               for the second sorting pass.
  961. FUNCTION {bib.sort.order}
  962. { sort.label
  963.   "    "
  964.   year field.or.null sortify
  965.   "    "
  966.   title field.or.null
  967.   sort.format.title
  968.   #1 entry.max$ substring$
  969.   'sort.key$ :=
  970. ITERATE {bib.sort.order}
  971. SORT            % by sort.label, year, title---giving final bibliography order
  972. FUNCTION {begin.bib}
  973. { preamble$ empty$                              % no \etalchar in apalike
  974.     'skip$
  975.     { preamble$ write$ newline$ }
  976.   if$
  977.   "\begin{thebibliography}{}" write$ newline$           % no labels in apalike
  978. EXECUTE {begin.bib}
  979. EXECUTE {init.state.consts}
  980. ITERATE {call.type$}
  981. FUNCTION {end.bib}
  982. { newline$
  983.   "\end{thebibliography}" write$ newline$
  984. EXECUTE {end.bib}
  985.